package com.zhipu.resetbalance.pop.inspector;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.CenterPopupView;
import com.zhipu.resetbalance.R;
import com.zhipu.resetbalance.listener.ChooseClickCallback1;
import com.zhipu.resetbalance.mobile.event.InspectorEntity;
import com.zhipu.resetbalance.utils.InitializeUtils;

public class AddInspectorPopup extends CenterPopupView {
    /**
     *
     */
    private InspectorEntity mInspectorEntity;

    public AddInspectorPopup(@NonNull Context context) {
        super(context);
    }



    public AddInspectorPopup(@NonNull Context context,InspectorEntity mInspectorEntity) {
        super(context);
        this.mInspectorEntity = mInspectorEntity;
    }

    @Override
    protected int getImplLayoutId() {
        return  R.layout.popup_add_inspector;
    }


    @Override
    protected void onCreate() {
        super.onCreate();
        EditText NameTester = findViewById(R.id.NameTester);
        if(null != mInspectorEntity){
            NameTester.setText(mInspectorEntity.InspectorName);
        }
        /**
         * 关闭
         */
        findViewById(R.id.Cancel).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        /**
         * 确认添加
         */
        findViewById(R.id.ConfirmAdd).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if(TextUtils.isEmpty(NameTester.getText().toString())){
                    InitializeUtils.getDefaultMaker().show("请输入姓名");
                    return;
                }
                mChooseClickCallback1.onChooseClickCallback(NameTester.getText().toString());
                dismiss();
            }
        });
    }

    private ChooseClickCallback1 mChooseClickCallback1;
    public void setChooseClickCallback1(ChooseClickCallback1 mChooseClickCallback1) {
        this.mChooseClickCallback1 = mChooseClickCallback1;
    }
}
